/* eslint-disable */
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue';
import GeminiScrollbar from 'vue-gemini-scrollbar';
import np from 'nprogress';
import axios from 'axios';
import 'nprogress/nprogress.css';
import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import 'quill/dist/quill.bubble.css';
import 'quill-emoji/dist/quill-emoji.css';
import Quill from 'quill';
import Emoji from 'quill-emoji/dist/quill-emoji';
import ImagePaste from '@/assets/quill_image_paste';
import App from './App';
import store from './store/index';
import router from './router';
import valert from './plugins/alert';
import vconfirm from './plugins/confirm';

Quill.register({
  'modules/quill-emoji': Emoji,
  'modules/imagePaste': ImagePaste,
}, true);

axios.defaults.baseURL = 'http://123.206.41.36:8080/';
// axios.defaults.baseURL = 'http://127.0.0.1:8080/';
axios.interceptors.request.use((config) => {
  np.start();
  return config;
});
axios.interceptors.response.use((response) => {
  np.done();
  return response;
});


// Date格式化
Date.prototype.Format = function (fmt) {
  const formatter = {
    'M+': this.getMonth() + 1, // 月份
    'd+': this.getDate(), // 日
    'H+': this.getHours(), // 小时
    'm+': this.getMinutes(), // 分
    's+': this.getSeconds(), // 秒
    'q+': Math.floor((this.getMonth() + 3) / 3), // 季度
    S: this.getMilliseconds(), // 毫秒
  };
  if (/(y+)/.test(fmt)) {
    fmt = fmt.replace(RegExp.$1, (`${this.getFullYear()}`).substr(4 - RegExp.$1.length));
  }
  for (const k in formatter) {
    if (new RegExp(`(${k})`).test(fmt)) {
      fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1)
        ? (formatter[k])
        : ((`00${formatter[k]}`).substr((`${formatter[k]}`).length)));
    }
  }
  return fmt;
};

Vue.config.productionTip = false;
Vue.use(valert);
Vue.use(vconfirm);
Vue.use(GeminiScrollbar);

router.beforeEach((to, from, next) => {
  np.start();
  next();
});
router.afterEach(() => {
  np.done();
});

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>',
});
